<template>
  <v-dialog :value="value" @input="$emit('input', false)">
    <popupVue
      v-if="value"
      @close="$emit('input', false)"
      :columns="columns"
      :filters="filters"
      req_url="/api/RepairReport/ProductTagPageList"
    >
      <template #title> 设备资产明细 </template>
      <template #sub-title>
        {{ sub_title }}
      </template>
    </popupVue>
  </v-dialog>
</template>

<script>
import popupVue from "./popup.vue";
import { getColumns } from "../../../generate";
import { distinct, num_split } from "../../../utils.js";

export default {
  components: {
    popupVue,
  },
  props: {
    value: Boolean,
    filters: {
      type: Array,
      defaults: [],
    },
    sub_title: String,
  },
  data() {
    return {
      columns: [],
    };
  },
  async mounted() {
    let arr = await getColumns("ProductTagModel");
    this.columns = distinct(
      [
        ...arr.filter((x) => x.Name != "EquipmentEnCode"),
        {
          Name: "Price2",
          render: (h, r) => h("div", null, num_split(r.Price2, 0)),
        },
        {
          Name: "Price",
          render: (h, r) => h("div", null, num_split(r.Price, 0)),
        },
        {
          Name: "SubscriptionDate",
          width: "140px",
          render: (h, r) => {
            let value = ``;

            if (r && r.SubscriptionDate) {
              value = r.SubscriptionDate.substring(0, 10);
            }

            return h("span", {}, value);
          },
        },
        {
          Name: "BidWinningDate",
          width: "140px",
          render: (h, r) => {
            let value = ``;

            if (r && r.BidWinningDate) {
              value = r.BidWinningDate.substring(0, 10);
            }

            return h("span", {}, value);
          },
        },
        {
          Name: "StoragePeriodTime",
          width: "140px",
          render: (h, r) => {
            let value = ``;

            if (r && r.StoragePeriodTime) {
              value = r.StoragePeriodTime.substring(0, 10);
            }

            return h("span", {}, value);
          },
        },
        {
          Name: "StartTime",
          width: "140px",
          render: (h, r) => {
            let value = ``;

            if (r && r.StartTime) {
              value = r.StartTime.substring(0, 10);
            }

            return h("span", {}, value);
          },
        },
      ],
      (v) => v.Name,
      (a, b) => ({ ...a, ...b })
    );
  },
};
</script>

<style>
</style>